/**
 * State of each register during assembler code generation.
 * @author Bennet,MLB
 *
 */
public class VSMRegDesc implements VSMCGConstants {
	private Operand3a memory;
	// memory associated with register
	private boolean modified;
	// true if the content of memory is different from those of the register
	
	public VSMRegDesc(){
		memory = null;
		modified = false;
	}
	
	public Operand3a getMemory(){
		return memory;
	}
	
	public boolean getModif(){
		return modified;
	}
	
	/**
	 * if cleared, the register is no more associated with a variable
	 */
	public void clear(){
		memory = null;
		modified = false;		
	}
	
	/**
	 * dump the register content in the associated memory, if different
	 */ 
	public void spill(int n){
		if (modified) {
			System.out.println(R_INDENT +"STI  R"+ n +","+ memory.getOffset() +
					"(R"+ R_STACK +")");
			modified = false;
		}
	}
	
	/**
	 * set the attributes
	 */
	public void set(Operand3a mem, boolean mod){
		memory = mem;
		modified = mod;
	}
	
}
